package com.gome.boot.config.mq.rocketmq;

/**
 * RocketMq工具类.
 *
 * @author baoxiufeng
 */
public class RocketMqUtil {
    private static RocketMqUtil util = new RocketMqUtil();

    private RocketMqUtil() {
    }

    /**
     * 获取RocketMq工具类实例.
     *
     * @return RocketMq工具类实例
     */
    public static RocketMqUtil getUtil() {
        return util;
    }

    /**
     * MQ消息ID维护对象.
     */
    private static final ThreadLocal<String> holderByMsgId = new ThreadLocal<String>();

    /**
     * 添加消息ID到维护对象中.
     *
     * @param msgId MQ消息ID
     */
    public void setMsgId(String msgId) {
        holderByMsgId.set(msgId);
    }

    /**
     * 从维护对象中获取消息ID.
     *
     * @return MQ消息ID
     */
    public String getMsgId() {
        return holderByMsgId.get();
    }
}
